class ListNode(object):
    def __init__(self, value):
        self.val = value
        self.next = None

    def __repr__(self) -> str:
        if not self.next:
            return str(self.val)
        else:
            return "{} -> {}".format(self.val, self.next.__repr__())


def create_list(ls):
    if ls:
        node = ListNode(ls[0])
        node.next = create_list(ls[1:])
        return node
    else:
        return None


if __name__ == "__main__":
    print(create_list([1, 2, 3, 4, 5]))
